package com.game.service.imp;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Service;

import com.game.comm.MessageType;
import com.game.modal.InMessage;
import com.game.service.IConsumer;
import com.game.service.IMessageService;
import com.game.service.IProducer;
import com.game.util.Constant;
import com.game.util.GsonUtils;
import com.google.gson.Gson;
@Service
public class ActiveMqConsumer implements IConsumer{
	private static final Logger log = LoggerFactory.getLogger(ActiveMqConsumer.class);

	@Autowired
	private IMessageService messageService;
	
	@JmsListener(destination = Constant.GAME_REQUEST_TOPIC)
	public void receive(String message) {
		log.debug("game logic server activeMq 收到消息{}"+message);
		InMessage msg = GsonUtils.gsonToBean(message, InMessage.class);
		if(MessageType.POINT.equals(msg.getType())){
			messageService.handMsg(msg);
		}else if(MessageType.MSG.equals(msg.getType())){
			messageService.handMsg(msg);
		}
	}
}
